﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Problem4
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedSet<int> palindromics = new SortedSet<int>();
            for (int a = 999; a >= 100; a--)
            {
                for (int b = a; b >= 100; b--)
                {
                    int num = a * b;
                    if (IsPalindromic(num))
                    {
                        palindromics.Add(num);
                    }
                }
            }

            Console.WriteLine(palindromics.Last());
            Console.ReadKey();
        }

        private static bool IsPalindromic(int num)
        {
            string asString = num.ToString();
            string reversed = new string(asString.Reverse().ToArray<char>());

            if (asString.Equals(reversed))
            {
                return true;
            }
            return false;
        }
    }
}
